/*
 * CustomerBO.java
 *
 * Created on February 12, 2007, 9:10 PM
 *
 */

package edu.byu.isys413.group1E.data;

/** This object contains all necessary information for a Customer in the current
 *database.
 *
 * @author Travis Kulbeth
 */
public class CustomerBO {
    
    private String custID = "";
    private String custFirstName = "";
    private String custMI = "";
    private String custLastName = "";
    private String custPhone = "";
    private String custEmail = "";
    private String custAddr = "";
    private String custCity = "";
    private String custState = "";
    private String custZip = "";
    private MembershipBO custMembership = null;
    private boolean alreadyInDB = false;
    private boolean isDirty = true;
    
    /**
     * Creates a new instance of CustomerBO
     * @param custID contains the given id for the customer
     */
    CustomerBO(String custID) {
        setCustID(custID);
        setAlreadyInDB(false);
        setIsDirty(true);
    }
    
    /**
     * Creates a new instance of CustomerBO with all of the provided information
     * @param id contains the given id
     * @param fName contains the given first name
     * @param mi contains the given middle initial
     * @param lName contains the given last name
     * @param addr contains the given address
     * @param city contains the given city
     * @param state contains the given state
     * @param zip contains the given zip (postal code)
     * @param phone contains the given phone number
     * @param email contains the given email address
     * @param member contains the given membership ID
     */
    CustomerBO(String id, String fName, String mi, String lName, String addr, String city, 
            String state, String zip, String phone, String email, MembershipBO member){
        setCustID(id);
        setCustFirstName(fName);
        setCustMI(mi);
        setCustLastName(lName);
        setCustPhone(phone);
        setCustEmail(email);
        setCustAddr(addr);
        setCustCity(city);
        setCustState(state);
        setCustZip(zip);
        setCustMembership(member);
    }

    /** Returns the customer ID
     * 
     * @return custID
     */
    public String getCustID() {
        return custID;
    }

    /** Sets the customer ID
     * 
     * @param custID contains the given custID
     */
    public void setCustID(String custID) {
        setIsDirty(true);
        this.custID = custID;
    }

    /** Returns the customer's first name
     * 
     * @return custFirstName
     */
    public String getCustFirstName() {
        return custFirstName;
    }

    /** Sets the customer's first name
     * 
     * @param custFirstName contains the given first name
     */
    public void setCustFirstName(String custFirstName) {
        setIsDirty(true);
        this.custFirstName = custFirstName;
    }

    /** Returns the customer's middle initial
     * 
     * @return custMI
     */
    public String getCustMI() {
        return custMI;
    }

    /** Sets the customer's middle initial
     * 
     * @param custMI contains the given middle initial
     */
    public void setCustMI(String custMI) {
        setIsDirty(true);
        this.custMI = custMI;
    }

    /** Returns the customer's given last name
     * 
     * @return custLastName
     */
    public String getCustLastName() {
        return custLastName;
    }

    /** Sets the customer's last name
     * 
     * @param custLastName contains the given last name
     */
    public void setCustLastName(String custLastName) {
        setIsDirty(true);
        this.custLastName = custLastName;
    }
    
    /** Returns the customer's full name in a string format (i.e., John D. Doe)
     * 
     * @return fullName
     */
    public String getCustFullName() {
        String fullName = new String(this.getCustFirstName() + " " + this.getCustMI() + " " + this.getCustLastName());
        return fullName;
    }

    /** Gets the customer's phone number
     * 
     * @return custPhone
     */
    public String getCustPhone() {
        return custPhone;
    }

    /** Sets the customer's phone number
     * 
     * @param custPhone contains the given phone number
     */
    public void setCustPhone(String custPhone) {
        setIsDirty(true);
        this.custPhone = custPhone;
    }

    /** Returns the customer's email address
     * 
     * @return custEmail
     */
    public String getCustEmail() {
        return custEmail;
    }

    /** Sets the customer's email address
     * 
     * @param custEmail contains the customer's email address
     */
    public void setCustEmail(String custEmail) {
        setIsDirty(true);
        this.custEmail = custEmail;
    }

    /** Returns the customer's street address
     * 
     * @return custAddr
     */
    public String getCustAddr() {
        return custAddr;
    }

    /** Sets the customer's street address
     * 
     * @param custAddr contains the given street address
     */
    public void setCustAddr(String custAddr) {
        setIsDirty(true);
        this.custAddr = custAddr;
    }

    /** Returns the customer's city
     * 
     * @return custCity
     */
    public String getCustCity() {
        return custCity;
    }

    /** Sets the customer's city
     * 
     * @param custCity contains the customer's city
     */
    public void setCustCity(String custCity) {
        setIsDirty(true);
        this.custCity = custCity;
    }

    /** Returns the customer's state
     * 
     * @return custState
     */
    public String getCustState() {
        return custState;
    }

    /** Sets the customer's state
     * 
     * @param custState contains the customer's state
     */
    public void setCustState(String custState) {
        setIsDirty(true);
        this.custState = custState;
    }

    /** Returns the customer's zip code
     * 
     * @return custZip
     */
    public String getCustZip() {
        return custZip;
    }

    /** Sets the customer's zip code
     * 
     * @param custZip contains the given zip code
     */
    public void setCustZip(String custZip) {
        setIsDirty(true);
        this.custZip = custZip;
    }

    /** Returns the membership object for this customer if it has one
     * 
     * @return custMembership
     */
    public MembershipBO getCustMembership() {
        return custMembership;
    }

    /** Sets the customer Membership
     * 
     * @param member contains the MembershipBO
     */
    public void setCustMembership(MembershipBO member) {
        setIsDirty(true);
        this.custMembership = member;
    }
    
    /** Sets if the object has been saved to the DB.
     * 
     * @param is indicates if the object has been saved to the DB.
     */
    public void setAlreadyInDB(boolean is){
        setIsDirty(true);
        this.alreadyInDB = is;
    }

    /** Returns if the object has already been saved.
     * 
     * @return alreadyInDB
     */
    public boolean isAlreadyInDB() {
        return alreadyInDB;
    }

    /** Returns if information has been changed if the object needs to be re-saved.
     * 
     * @return isDirty
     */
    public boolean isIsDirty() {
        return isDirty;
    }

    /** Sets if info has changed.
     * 
     * @param isDirty indicates if information has changed
     */
    public void setIsDirty(boolean isDirty) {
        this.isDirty = isDirty;
    }
}
